package com.yunhai.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunhai.system.domain.ProductType;
import com.yunhai.system.mapper.ProductTypeMapper;
import com.yunhai.system.service.ProductTypeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品类型表(TProductType)表服务实现类
 *
 * @author makejava
 * @since 2021-01-09 18:01:51
 */
@Service("productTypeService")
public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, ProductType> implements ProductTypeService {

    @Override
    public List<ProductType> queryList(ProductType productType) {
        LambdaQueryWrapper<ProductType> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(productType.getTypeName())){
            lqw.like(ProductType::getTypeName ,productType.getTypeName());
        }
        if (productType.getParentId() != null){
            lqw.eq(ProductType::getParentId ,productType.getParentId());
        }
        if (productType.getLanguage() != null){
            lqw.eq(ProductType::getLanguage ,productType.getLanguage());
        }
        lqw.orderByDesc(ProductType::getCreateTime);
        return this.list(lqw);
    }
}